//
//  VideoTestViewController.m
//  TestPrj
//
//  Created by 朱铅峰 on 2020/1/8.
//  Copyright © 2020 Xing. All rights reserved.
//

#import "VideoTestViewController.h"
#import "DrawingBoardViewController.h"
#import "ZFPlayerTestViewController.h"
#import "VideoEditViewController.h"
#import "JFLiveShowVC.h"
#import "KtvhttpCacheTestViewController.h"
#import "WebRTCViewController.h"
#import "VRPlayerViewController.h"

@interface VideoTestViewController ()

@property(nonatomic,strong)NSArray *dataSource;

@end

@implementation VideoTestViewController

- (void)loadView {
    
    [super loadView];
    
    UIButton *returnBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    returnBtn.frame = CGRectMake(0, 0, 44, 44);
    returnBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [returnBtn setTitle:@"返回" forState:UIControlStateNormal];
    [returnBtn addTarget:self action:@selector(dismissAction) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:returnBtn];
}

- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    self.dataSource = @[@"DrawingBoard(图片转视频)",
                        @"ZFPlayer(视频播放)",
                        @"VideoTool(视频编辑)",
                        @"KTVHTTPCache实现边看边下载(本地http代理服务实现)",
                        @"JFLivePlayer录屏直播",
                        @"WebRTC实现端对端视频语音通话",
                        @"VR全景播放器（OpenGL滤镜）"
    ];
    
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"seHomeCell"];
}

- (void)dismissAction {
    
    [self.navigationController dismissViewControllerAnimated:YES completion:nil];
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return _dataSource.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"seHomeCell"];
    cell.backgroundColor = [UIColor clearColor];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.textLabel.numberOfLines = 0;
    cell.textLabel.numberOfLines = 2;
    
    NSString *title = _dataSource[indexPath.row];
    cell.textLabel.text = title;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    NSInteger index = indexPath.row;
    
    if (index == 0) {
        
        DrawingBoardViewController *vc = [[DrawingBoardViewController alloc] init];
        [self.navigationController pushViewController:vc animated:YES];
    
    } else if (index == 1) {
        
        ZFPlayerTestViewController *vc = [ZFPlayerTestViewController new];
        UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
        nav.modalPresentationStyle = UIModalPresentationFullScreen;
        [self presentViewController:nav animated:YES completion:nil];
    
    } else if (index == 2) {
        
        VideoEditViewController *vc = [VideoEditViewController new];
        [self.navigationController pushViewController:vc animated:YES];
        
    } else if (index == 3) {
        
        KtvhttpCacheTestViewController *vc = [KtvhttpCacheTestViewController new];
        [self.navigationController pushViewController:vc animated:YES];
    
    } else if (index == 4) {
        
        JFLiveShowVC *vc = [[JFLiveShowVC alloc] init];
        [self.navigationController pushViewController:vc animated:YES];
    
    } else if (index == 5) {
        
        NSLog(@"当前为主线程：%@",[[NSThread currentThread] isMainThread]?@"是":@"否");
        WebRTCViewController *vc = [[WebRTCViewController alloc] init];
        [self.navigationController pushViewController:vc animated:YES];
        
    } else if (index == 6) {
        
        VRPlayerViewController *vc = [[VRPlayerViewController alloc] initWithNibName:@"VRPlayerViewController" bundle:[NSBundle mainBundle]];
        [self.navigationController pushViewController:vc animated:YES];
    }
    
}

@end
